let obj =
    object(self)
        val mutable a = 0
        method get_a = a
        method set_a x = a <- x
    end;;

let rec loop i =
    obj#set_a (obj#get_a + 1);
    if (i > 0) then
        loop (i - 1);;

loop 1000000;;

print_int obj#get_a;;
print_string "\n";;
